<template>
  <div class="Loading">
    <div class="Enroll-panel">
      <el-form
        :model="dynamicValidateForm"
        ref="dynamicValidateForm"
        label-width="100px"
        class="demo-dynamic"
      >
        <el-form-item label="参赛院校名称">
          <el-input v-model="dynamicValidateForm.school"></el-input>
        </el-form-item>
        <el-form-item
          v-for="(domain, index) in dynamicValidateForm.domains"
          label="教师信息"
          :key="domain.key"
        >
          <el-input
            v-model="domain.value"
            @focus="TeacherFocus(index)"
            placeholder="点击获取详情"
          ></el-input
          ><el-button @click.prevent="removeDomain(domain)">删除</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="addDomain">新增教师</el-button>
        </el-form-item>
        <el-form-item
          v-for="(Student, index) in dynamicValidateForm.Student"
          label="选手信息"
          :key="Student.key"
        >
          <el-input
            v-model="Student.value"
            @focus="StudentFocus(index)"
          ></el-input>
          <el-button @click.prevent="removeStudentDomain(Student)"
            >删除</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button @click="addStudentDomain">新增学生</el-button>
          <!-- <el-button @click="resetForm('dynamicValidateForm')">重置</el-button> -->
        </el-form-item>
      </el-form>
    </div>
    <!-- 表单 -->
    <div class="StudentForm">
      <el-dialog title="学生信息" :visible.sync="StudentdialogFormVisible">
        <el-form :model="StudentForm">
          <el-form-item label="姓名" :label-width="formLabelWidth">
            <el-input v-model="StudentForm.Name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="专业" :label-width="formLabelWidth">
            <el-input v-model="StudentForm.Specialty" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="移动电话" :label-width="formLabelWidth">
            <el-input v-model="StudentForm.Ipone" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="指导教师" :label-width="formLabelWidth">
            <el-input v-model="StudentForm.GuidanceTeacher" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="StudentdialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="StudentdialogFormVisible = false"
            >确 定</el-button
          >
        </div>
      </el-dialog>
    </div>
    <div class="TeacherForm">
      <el-dialog title="教师" :visible.sync="TeacherdialogFormVisible">
        <el-form :model="TeacherForm">
          <el-form-item label="姓名" :label-width="formLabelWidth">
            <el-input v-model="TeacherForm.Name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="固定电话" :label-width="formLabelWidth">
            <el-input v-model="TeacherForm.FixedTelephone" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="移动电话" :label-width="formLabelWidth">
            <el-input v-model="TeacherForm.Ipone" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="职务/职称" :label-width="formLabelWidth">
            <el-input v-model="TeacherForm.Post" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="QQ" :label-width="formLabelWidth">
            <el-input v-model="TeacherForm.Qq" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="TeacherdialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="TeacherdialogFormVisible = false"
            >确 定</el-button
          >
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
export default {
  name: "Loding",
  components: {},
  props: {},
  data() {
    return {
      dynamicValidateForm: {
        domains: [
          {
            value: "",
          },
        ],
        Student: [
          {
            value: "",
          },
        ],
        school: "",
      },
      StudentdialogFormVisible:false,
      TeacherdialogFormVisible:false,
      StudentForm: {
        Name:"",
        Specialty:"",
        Ipone:"",
        GuidanceTeacher:""
      },
      TeacherForm: {
        Name:"",
        FixedTelephone:"",
        Ipone:'',
        Post:"",
        Qq:''
      },
      formLabelWidth: '150px'
      
    };
  },
  methods: {
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    removeDomain(item) {
      var index = this.dynamicValidateForm.domains.indexOf(item);
      if (index !== -1) {
        this.dynamicValidateForm.domains.splice(index, 1);
      }
    },
    removeStudentDomain(item) {
      var index = this.dynamicValidateForm.Student.indexOf(item);
      if (index !== -1) {
        this.dynamicValidateForm.Student.splice(index, 1);
      }
    },
    addDomain() {
      this.dynamicValidateForm.domains.push({
        value: "",
        key: Date.now(),
      });
    },
    addStudentDomain() {
      this.dynamicValidateForm.Student.push({
        value: "",
        key: Date.now(),
      });
    },
    TeacherFocus(index) {
      this.TeacherdialogFormVisible =true
      console.log("你好啊");
      console.log(index);
    },
    StudentFocus(index) {
      this.StudentdialogFormVisible =true
      console.log("你好啊");
      console.log(index);
    },
  },
  created() {},
  mounted() {},
};
</script>
<style spcoed lang="less">
.Loading {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
.Enroll-panel {
  position: absolute;
  width: 600px;
  height: 300px;
}
.Loading .el-input {
  width: 60%;
}
.Loading .el-button {
  margin-left: 10px;
}
// .el-form-item .el-form-item__content > button:nth-child(2) {
//   position: absolute;
//   left: 525px;
// }
.StudentForm .el-dialog {
  width: 600px;
  height: 500px;
  border-radius: 20px;
}
.StudentForm .el-dialog__footer {
  position: absolute;
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.TeacherForm .el-dialog {
  width: 600px;
  height: 500px;
  border-radius: 20px;
}
.TeacherForm .el-dialog__footer {
  position: absolute;
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
